<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="ctx" th:content="${#httpServletRequest.getContextPath()}"/>
    <title>新潮广告发布系统</title>
    <link rel="stylesheet" th:href="@{/css/admin/base.css}">
    <link rel="stylesheet" th:href="@{/lib/font-awesome/4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/css/admin/app.css}">
</head>

<body>
<div class="app">
    <div class="app-header">
        <div class="title">新潮广告发布系统</div>
        <div class="user">
            <span id="userNameSpan" class="name"></span>
            <ul>
                <li>
                    <a th:href="@{/logout}">退出</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="app-container">
        <div class="app-aside">
            <div id="menu"></div>
        </div>
        <div class="app-main">
            <!-- 初始页面地址 -->
            <iframe th:src="@{/web/goHome}" frameborder="0"></iframe>
        </div>
    </div>
</div>

<script th:src="@{/lib/jquery.min.js}"></script>
<script th:src="@{/js/admin/index.js}"></script>
<script th:src="@{/js/menu.js}"></script>
<script type="text/javascript" th:inline="javascript">
    //获取context path
    var context = $("meta[name='ctx']").attr("content") || '';
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: context +'/web/getMenuDatas',
        data: {},
        cache: false,
        async: true,
        success: function (result) {
            if (result.code == 0) {
                var menu = new Menu('#menu', {
                    data: result.data,
                    context:context
                })
            } else {
                popup.tipsTop(result.msg, 'warning');
            }
        }
    });

    //获取用户名
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: context +'/web/getUser',
        data: {},
        cache: false,
        async: true,
        success: function (result) {
            if (result.code == 0) {
                var user = result.data;
                var userName = user['userName'];
                $("#userNameSpan").text(userName);
            } else {
                popup.tipsTop(result.msg, 'warning');
            }
        }
    });
</script>
</body>

</html>